//
//  MCThirdAGDailyReportTableViewCell.m
//  LDYL
//
//  Created by MC on 2018/7/10.
//  Copyright © 2018年 TLYL01. All rights reserved.
//

#import "MCThirdAGDailyReportTableViewCell.h"
#import "MCDataTool.h"
#import "MCQiPaiReportTool.h"


@interface MCThirdAGDailyReportTableViewCell ()

@property (nonatomic,strong)UIImageView * logoImgV;
@property (nonatomic,strong)UILabel * timeLab;
//总投注：20000.00  中奖金额：20000.00
//有效投注：         视讯盈亏
//电子盈亏         桌面盈亏
//捕鱼王盈亏        其他收入
//总盈亏：25000.00



//总投注：20000.00
@property (nonatomic,strong)UILabel * tzMoneyLabel;
//有效投注
@property (nonatomic,strong)UILabel * yxtzMoneyLabel;
//电子盈亏
@property (nonatomic,strong)UILabel * dianZiYinKuiMoneyLabel;
//捕鱼王盈亏
@property (nonatomic,strong)UILabel * buYuWangYinKuiMoneyLabel;



//中奖金额：20000.00
@property (nonatomic,strong)UILabel * zhongJiangMoney;
//视讯盈亏
@property (nonatomic,strong)UILabel * shiXunYinKuiMoneyLabel;
//桌面盈亏
@property (nonatomic,strong)UILabel * zhuoMianYinKuiMoneyLabel;
//其他收入
@property (nonatomic,strong)UILabel * otherMoneyLabel;

//总盈亏：25000.00
@property (nonatomic,strong)UILabel * yinKuiMoney;


@end

@implementation MCThirdAGDailyReportTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self){
        [self initView];
    }
    return self;
}

- (void)initView{
    
    self.backgroundColor=[UIColor clearColor];
    //     self.backgroundColor=[UIColor yellowColor];
    CGFloat font =12;
    if (G_SCREENWIDTH<370) {
        font=10;
    }
    
    UIView * back=[[UIView alloc]init];
    [self addSubview:back];
    back.backgroundColor=[UIColor whiteColor];
    //    back.backgroundColor=[UIColor blueColor];
    
    back.frame=CGRectMake(13, 0, G_SCREENWIDTH-26, GetHeightWithLineCount(AGQiPaiReportLineCount));
    back.layer.cornerRadius=6;
    back.clipsToBounds=YES;
    
    /*
     * logo
     */
    _logoImgV=[[UIImageView alloc]init];
    _logoImgV.backgroundColor=[UIColor whiteColor];
    [back addSubview:_logoImgV];
    _logoImgV.layer.cornerRadius=11;
    _logoImgV.clipsToBounds=YES;
    _logoImgV.image=[UIImage imageNamed:@"hjicon"];
    _logoImgV.frame=CGRectMake(22, 16, 22, 22);
    
    /*
     * 时间
     */
    _timeLab =[[UILabel alloc]init];
    _timeLab.textColor=RGB(46,46,46);
    _timeLab.font=[UIFont systemFontOfSize:font];
    _timeLab.text =@"加载中";
    _timeLab.textAlignment=NSTextAlignmentLeft;
    [self  addSubview:_timeLab];
    
    [_timeLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(_logoImgV.mas_centerY).offset(0);
        make.left.equalTo(_logoImgV.mas_right).offset(7);
        make.width.mas_equalTo(200);
        make.height.mas_equalTo(20);
    }];
    
    UIView * centerView=[[UIView alloc]init];
    [self addSubview:centerView];
    centerView.backgroundColor=[[UIColor colorWithHexString:@"#ffa044"] colorWithAlphaComponent:0.13];//RGB(246,243,248);//RGB(246,243,248);
    //    centerView.backgroundColor=[UIColor cyanColor];
    centerView.frame=CGRectMake(33, 50, G_SCREENWIDTH-60, 20+30*AGQiPaiReportLineCount);
    centerView.layer.cornerRadius=5;
    centerView.clipsToBounds=YES;
    
    
    
    
    //总投注：20000.00
    UILabel * tzMoney=[self GetAdaptiveLable:GetQiPaiReportFirstLabelFrame(0, 0) AndText:@"总  投  注:" andFont:font andTextColor:RGB(46,46,46) andTextAlignment:NSTextAlignmentLeft];
    [centerView addSubview:tzMoney];
    UILabel * tzMoneyLabel=[self GetAdaptiveLable:GetQiPaiReportSecondLabelFrame(0, 0) AndText:@"加载中" andFont:font andTextColor:RGB(102,102,102) andTextAlignment:NSTextAlignmentLeft];
    [centerView addSubview:tzMoneyLabel];
    _tzMoneyLabel=tzMoneyLabel;
    
    
    //中奖金额：20000.00
    UILabel * zhongJiang=[self GetAdaptiveLable:GetQiPaiReportFirstLabelFrame(1, 0) AndText:@"中奖金额:" andFont:font andTextColor:RGB(46,46,46) andTextAlignment:NSTextAlignmentLeft];
    [centerView addSubview:zhongJiang];
    UILabel * zhongJiangMoney=[self GetAdaptiveLable:GetQiPaiReportSecondLabelFrame(1, 0) AndText:@"加载中" andFont:font andTextColor:RGB(102,102,102) andTextAlignment:NSTextAlignmentLeft];
    [centerView addSubview:zhongJiangMoney];
    _zhongJiangMoney=zhongJiangMoney;
    
    //有效投注：20000.00
    UILabel * yxtzMoney=[self GetAdaptiveLable:GetQiPaiReportFirstLabelFrame(0, 1) AndText:@"有效投注:" andFont:font andTextColor:RGB(46,46,46) andTextAlignment:NSTextAlignmentLeft];
    [centerView addSubview:yxtzMoney];
    UILabel * yxtzMoneyLabel=[self GetAdaptiveLable:GetQiPaiReportSecondLabelFrame(0, 1) AndText:@"加载中" andFont:font andTextColor:RGB(102,102,102) andTextAlignment:NSTextAlignmentLeft];
    [centerView addSubview:yxtzMoneyLabel];
    _yxtzMoneyLabel=yxtzMoneyLabel;
    
    //视讯盈亏
    UILabel * shiXunYinKui=[self GetAdaptiveLable:GetQiPaiReportFirstLabelFrame(1, 1) AndText:@"视讯盈亏:" andFont:font andTextColor:RGB(46,46,46) andTextAlignment:NSTextAlignmentLeft];
    [centerView addSubview:shiXunYinKui];
    UILabel * shiXunYinKuiMoneyLabel=[self GetAdaptiveLable:GetQiPaiReportSecondLabelFrame(1, 1) AndText:@"加载中" andFont:font andTextColor:RGB(102,102,102) andTextAlignment:NSTextAlignmentLeft];
    [centerView addSubview:shiXunYinKuiMoneyLabel];
    _shiXunYinKuiMoneyLabel=shiXunYinKuiMoneyLabel;
    
    
    //电子盈亏
    UILabel * dianZiYinKui=[self GetAdaptiveLable:GetQiPaiReportFirstLabelFrame(0, 2) AndText:@"电子盈亏:" andFont:font andTextColor:RGB(46,46,46) andTextAlignment:NSTextAlignmentLeft];
    [centerView addSubview:dianZiYinKui];
    UILabel * dianZiYinKuiMoneyLabel=[self GetAdaptiveLable:GetQiPaiReportSecondLabelFrame(0, 2) AndText:@"加载中" andFont:font andTextColor:RGB(102,102,102) andTextAlignment:NSTextAlignmentLeft];
    [centerView addSubview:dianZiYinKuiMoneyLabel];
    _dianZiYinKuiMoneyLabel=dianZiYinKuiMoneyLabel;
    
    
    //桌面盈亏
    UILabel * zhuoMianYinKui=[self GetAdaptiveLable:GetQiPaiReportFirstLabelFrame(1, 2) AndText:@"桌面盈亏:" andFont:font andTextColor:RGB(46,46,46) andTextAlignment:NSTextAlignmentLeft];
    [centerView addSubview:zhuoMianYinKui];
    UILabel * zhuoMianYinKuiMoneyLabel=[self GetAdaptiveLable:GetQiPaiReportSecondLabelFrame(1, 2) AndText:@"加载中" andFont:font andTextColor:RGB(102,102,102) andTextAlignment:NSTextAlignmentLeft];
    [centerView addSubview:zhuoMianYinKuiMoneyLabel];
    _zhuoMianYinKuiMoneyLabel=zhuoMianYinKuiMoneyLabel;
    
    //捕鱼王盈亏
    UILabel * buYuWangYinKui=[self GetAdaptiveLable:GetQiPaiReportFirstLabelFrame(0, 3) AndText:@"捕鱼王盈亏:" andFont:font andTextColor:RGB(46,46,46) andTextAlignment:NSTextAlignmentLeft];
    [centerView addSubview:buYuWangYinKui];
    UILabel * buYuWangYinKuiMoneyLabel=[self GetAdaptiveLable:GetQiPaiReportSecondLabelFrame(0, 3) AndText:@"加载中" andFont:font andTextColor:RGB(102,102,102) andTextAlignment:NSTextAlignmentLeft];
    [centerView addSubview:buYuWangYinKuiMoneyLabel];
    _buYuWangYinKuiMoneyLabel=buYuWangYinKuiMoneyLabel;
    
    //其他收入
    UILabel * otherMoney=[self GetAdaptiveLable:GetQiPaiReportFirstLabelFrame(1, 3) AndText:@"其他收入:" andFont:font andTextColor:RGB(46,46,46) andTextAlignment:NSTextAlignmentLeft];
    [centerView addSubview:otherMoney];
    UILabel * otherMoneyLabel=[self GetAdaptiveLable:GetQiPaiReportSecondLabelFrame(1, 3) AndText:@"加载中" andFont:font andTextColor:RGB(102,102,102) andTextAlignment:NSTextAlignmentLeft];
    [centerView addSubview:otherMoneyLabel];
    _otherMoneyLabel=otherMoneyLabel;
    
    //总盈亏：25000.00
    UILabel * yinKui=[self GetAdaptiveLable:GetQiPaiReportFirstLabelFrame(0, 4) AndText:@"总  盈  亏:" andFont:font andTextColor:RGB(46,46,46) andTextAlignment:NSTextAlignmentLeft];
    [centerView addSubview:yinKui];
    UILabel * yinKuiMoney=[self GetAdaptiveLable:GetQiPaiReportSecondLabelFrame(0, 4) AndText:@"加载中" andFont:font andTextColor:RGB(102,102,102) andTextAlignment:NSTextAlignmentLeft];
    [centerView addSubview:yinKuiMoney];
    _yinKuiMoney=yinKuiMoney;
    
}


-(UILabel *)GetAdaptiveLable:(CGRect)rect AndText:(NSString *)contentStr andFont:(CGFloat)font  andTextColor:(UIColor *)textColor andTextAlignment:(NSTextAlignment)textAlignment{
    
    
    UILabel *contentLbl = [[UILabel alloc] initWithFrame:rect];
    contentLbl.text = contentStr;
    contentLbl.numberOfLines = 0;
    contentLbl.textAlignment = textAlignment;
    contentLbl.font = [UIFont systemFontOfSize:font];
    contentLbl.textColor=textColor;
    contentLbl.clipsToBounds=YES;
    
    return contentLbl;
}


+(CGFloat)computeHeight:(id)info{
    
    return GetHeightWithLineCount(AGQiPaiReportLineCount)+10;
}

-(void)setDataSource:(MCThirdAGReportListModel *)dataSource{
    
    if (!dataSource) {
        return;
    }
    
    //总投注：20000.00
    _tzMoneyLabel.text=GetRealSNum(dataSource.BetAmount);
    //中奖金额：20000.00
    _zhongJiangMoney.text=GetRealSNum(dataSource.AwardAmount);
    //总盈亏：25000.00
    _yinKuiMoney.text=GetRealSNum(dataSource.TotalNetAmount);
    //    [MCDataTool changeYKLabelColor:_yinKuiMoney];
    NSDateFormatter *dataFormatter = [[NSDateFormatter alloc] init];
    [dataFormatter setDateFormat:@"yyyy-MM-dd HH:mm:ss"];
    NSDate *dateTemps = [dataFormatter dateFromString:dataSource.HisDate];
    [dataFormatter setDateFormat:@"yyyy-MM-dd"];
    NSString *dateTempMinStr = [dataFormatter stringFromDate:dateTemps];
    _timeLab.text=dateTempMinStr;
    
    [self setLabelWithData:dataSource.TotalNetAmount andLab:_yinKuiMoney];
    [self setLabelWithData:dataSource.DZNetAmount andLab:_dianZiYinKuiMoneyLabel];
    [self setLabelWithData:dataSource.BYNetAmount andLab:_buYuWangYinKuiMoneyLabel];
    [self setLabelWithData:dataSource.SXNetAmount andLab:_shiXunYinKuiMoneyLabel];
    [self setLabelWithData:dataSource.ZYNetAmount andLab:_zhuoMianYinKuiMoneyLabel];
    
    
    _yxtzMoneyLabel.text=dataSource.ValidBetAmount;
    
    //电子盈亏
    _dianZiYinKuiMoneyLabel.text = GetRealSNum(dataSource.DZNetAmount);
    
    //捕鱼王盈亏
    _buYuWangYinKuiMoneyLabel.text = GetRealSNum(dataSource.BYNetAmount);
    
    //视讯盈亏
    _shiXunYinKuiMoneyLabel.text = GetRealSNum(dataSource.SXNetAmount);
    //桌面盈亏
    _zhuoMianYinKuiMoneyLabel.text = GetRealSNum(dataSource.ZYNetAmount);
    
    _otherMoneyLabel.text = GetRealSNum(dataSource.OtherMoney);
}

/*
 * 设置颜色
 */
-(void)setLabelWithData:(NSString *)str andLab:(UILabel *)lab{
    NSString * PL =GetRealSNum(str);
    if ([PL isEqualToString:@"0"]) {
        lab.textColor=RGB(102, 102, 102);
    }else if([PL floatValue]<0){
        lab.textColor=[UIColor greenColor];
    }else{
        lab.textColor=RGB(249,84,83);
    }
}


- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];
    
    // Configure the view for the selected state
}

@end















